﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Eis51.CampanyCMS.Business.Bus;

using Eis51.Web.Admin;

namespace Eis51.CampanyCMS.WebUI.Admin.Coupon
{
    public partial class ViewCoup : BasePage
    {
        private string CouponNo
        {
            get
            {
                if (Request.QueryString["CouponNo"] != null)
                {
                    return Request.QueryString["CouponNo"];
                }
                return string.Empty ;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                ShowData();
            }
        }

        private void ShowData()
        {
            DataTable dt = CouponusedBLL.GetInstance().GetCouponusedData(this.CouponNo);
          dgCoupon.Data = dt;
          dgCoupon.DataBind();
        }



        protected void dgCoupon_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
        {
            switch (e.CommandName)
            {
                case "Delete":
                    CouponusedBLL.GetInstance().DeleteCouponused(int.Parse(e.Item.Cells[0].Text));
                    ShowData();
                    break;
                 
                default:
                    
                    break;
            }
        }

        protected void dgCoupon_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
        {


            if (e.Item.ItemType == ListItemType.AlternatingItem ||
                e.Item.ItemType == ListItemType.Item)
            {
                LinkButton btnDelete = e.Item.FindControl("btnDelete") as LinkButton;
                if (btnDelete != null)
                {
                    btnDelete.Attributes.Add("onclick", "javascript:return confirm('确定要删除吗?');");
                }
                
            }
        }
    }
}
